package com.user.action;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.user.entity.User;

import java.util.Map;

public class LoginInterceptor implements Interceptor {


    public void destroy() {

    }

    public void init() {

    }

    public String intercept(ActionInvocation actionInvocation) throws Exception {
        ActionContext context= ActionContext.getContext();
        Map<String ,Object> session=context.getSession();
        User user =(User) session.get("user");
        if(user!=null){
            return actionInvocation.invoke();
        }else{
            return "login";
        }
    }
}
